﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>XiTongAdd</title>
    <link href="~/layui-v2.6.8/layui/css/layui.css" rel="stylesheet" />
    <script src="~/layui-v2.6.8/layui/layui.js"></script>
    <script src="~/lib/jquery/dist/jquery.js"></script>
</head>
<body>
    <form class="layui-form" action="" id="AddForm">

        <div class="layui-form-item">
            <label class="layui-form-label">操作人</label>
            <div class="layui-input-inline">
                <input type="text" name="xpeople" id="xpeople" lay-verify="title" autocomplete="off" placeholder="操作人" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">菜单名称</label>
            <div class="layui-input-inline">
                <input type="text" name="xname" id="xname" lay-verify="title" autocomplete="off" placeholder="菜单名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">操作类型</label>
            <div class="layui-input-inline">
                <input type="text" name="Xtype" id="Xtype" lay-verify="title" autocomplete="off" placeholder="操作类型" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">IP地址</label>
            <div class="layui-input-inline">
                <input type="text" name="XIP" id="XIP" lay-verify="title" autocomplete="off" placeholder="地址" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">操作时间</label>
            <div class="layui-input-inline">
                <input type="text" name="Xtime" id="Xtime" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">日志内容</label>
            <div class="layui-input-block">
                <textarea placeholder="日志内容" class="layui-textarea" id="Xinfou" name="Xinfou"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script>
        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;

            //日期
            laydate.render({
                elem: '#Xtime'
            });
            laydate.render({
                elem: '#Xtime'
            });

            //创建一个编辑器
            var editIndex = layedit.build('LAY_demo_editor');



            //监听指定开关
            form.on('switch(switchTest)', function (data) {
                layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {
                    offset: '6px'
                });
                layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
            });

            //监听提交
            form.on('submit(demo1)', function (data) {
                $.ajax({
                    url: 'http://localhost:36862/api/JuSe/XTAdd',
                    data: $("#AddForm").serialize(),
                    type: 'post',
                    success: function (d) {
                        if (d > 0) {
                            layer.msg('添加成功!', { time: 2000, icon: 1 }, function () {
                                parent.location.href = '/XiTong/XiTongShow';
                            });
                        }
                        else {
                            layer.msg('添加失败!', { time: 2000, icon: 2 }, function () {
                                parent.location.href = '/XiTong/XiTongShow';
                            });
                        }

                    }
                })
                return false;//此处和Ajax平级
            })



            //表单赋值
            layui.$('#LAY-component-form-setval').on('click', function () {
                form.val('example', {
                    "username": "贤心" // "name": "value"
                    , "password": "123456"
                    , "interest": 1
                    , "like[write]": true //复选框选中状态
                    , "close": true //开关状态
                    , "sex": "女"
                    , "desc": "我爱 layui"
                });
            });

            //表单取值
            layui.$('#LAY-component-form-getval').on('click', function () {
                var data = form.val('example');
                alert(JSON.stringify(data));
            });

        });
    </script>
</body>
</html>
